package Boundry;

import javax.swing.JPanel;

import Boundry.GenericTools.IPanelOperation;
import Boundry.GenericTools.InputPanel;
import Controllers.GenericToolsForController.BrowseScreen;
import Controllers.GenericToolsForController.PDFfile;

import javax.swing.JLabel;
import java.awt.Font;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.border.TitledBorder;
import java.awt.SystemColor;
import javax.swing.JTextPane;
import java.awt.Color;
import java.util.Date;
import javax.swing.JTextArea;

public class TestingPanel extends InputPanel implements ActionListener , IPanelOperation{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	private BrowseScreen bs;
	private JTextField TxtCreationDate;
	

	private JTextField txtInitiator;
	private JTextField txtInfoSystem;
	private JButton btnTestingResult;
	

	private JTextPane txtPropChange;
	private JTextPane txtExcuse;
	private JTextPane txtNotes;
	private JTextPane txtDescription;
	private JPanel step3Pane;
	
	private JRadioButton RdbtnPassed;
	private JRadioButton RdbtnFailed;
	private JPanel FailReportPanel;
	




	private JTextArea textArea;

	/**
	 * Create the panel.
	 */
	public TestingPanel() {
		btnAskForMoreTime.setText("");
		//Create a file chooser
		bs = new BrowseScreen();
		
		JPanel step2Pane = new JPanel();
		step2Pane.setLayout(null);
		step2Pane.setBorder(new TitledBorder(null, "Step 2 : View Change Request Information", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		step2Pane.setBounds(10, 11, 876, 216);
		mainPanel.add(step2Pane);
		
		TxtCreationDate = new JTextField();
		TxtCreationDate.setEnabled(false);
		TxtCreationDate.setEditable(false);
		TxtCreationDate.setColumns(10);
		TxtCreationDate.setBackground(SystemColor.inactiveCaptionText);
		TxtCreationDate.setBounds(131, 130, 147, 20);
		step2Pane.add(TxtCreationDate);
		
		txtInitiator = new JTextField();
		txtInitiator.setEnabled(false);
		txtInitiator.setEditable(false);
		txtInitiator.setColumns(10);
		txtInitiator.setBackground(SystemColor.inactiveCaptionText);
		txtInitiator.setBounds(131, 161, 147, 20);
		step2Pane.add(txtInitiator);
		
		txtInfoSystem = new JTextField();
		txtInfoSystem.setEnabled(false);
		txtInfoSystem.setEditable(false);
		txtInfoSystem.setColumns(10);
		txtInfoSystem.setBackground(SystemColor.inactiveCaptionText);
		txtInfoSystem.setBounds(131, 189, 147, 20);
		step2Pane.add(txtInfoSystem);
		
		txtNotes = new JTextPane();
		txtNotes.setEnabled(false);
		txtNotes.setEditable(false);
		txtNotes.setBackground(SystemColor.inactiveCaptionText);
		txtNotes.setBounds(423, 22, 177, 59);
		step2Pane.add(txtNotes);
		
		txtPropChange = new JTextPane();
		txtPropChange.setEnabled(false);
		txtPropChange.setEditable(false);
		txtPropChange.setBackground(SystemColor.inactiveCaptionText);
		txtPropChange.setBounds(423, 143, 177, 66);
		step2Pane.add(txtPropChange);
		
		txtExcuse = new JTextPane();
		txtExcuse.setEnabled(false);
		txtExcuse.setEditable(false);
		txtExcuse.setBackground(SystemColor.inactiveCaptionText);
		txtExcuse.setBounds(423, 86, 177, 50);
		step2Pane.add(txtExcuse);
		
		txtDescription = new JTextPane();
		txtDescription.setForeground(Color.RED);
		txtDescription.setEnabled(false);
		txtDescription.setEditable(false);
		txtDescription.setBackground(SystemColor.inactiveCaptionText);
		txtDescription.setBounds(131, 22, 147, 97);
		step2Pane.add(txtDescription);
		
		JLabel label_1 = new JLabel("Notes :");
		label_1.setBounds(342, 22, 120, 14);
		step2Pane.add(label_1);
		
		JLabel label_2 = new JLabel("Info System:");
		label_2.setBounds(10, 192, 120, 14);
		step2Pane.add(label_2);
		
		JLabel label_3 = new JLabel("Initiator:");
		label_3.setBounds(10, 164, 120, 14);
		step2Pane.add(label_3);
		
		JLabel label_4 = new JLabel("Date of creation:");
		label_4.setBounds(10, 133, 120, 14);
		step2Pane.add(label_4);
		
		JLabel label_5 = new JLabel("Description:");
		label_5.setBounds(10, 22, 86, 14);
		step2Pane.add(label_5);
		
		JLabel label_6 = new JLabel("Proposed Change: ");
		label_6.setBounds(288, 166, 137, 14);
		step2Pane.add(label_6);
		
		JLabel label_7 = new JLabel("Excuse: ");
		label_7.setBounds(342, 86, 120, 14);
		step2Pane.add(label_7);
		
		btnTestingResult = new JButton("Testing result");
		btnTestingResult.setBounds(729, 159, 137, 50);
		step2Pane.add(btnTestingResult);
		//selectedItem=-1;
		btnTestingResult.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (e.getSource()== btnTestingResult){
        			step3Pane.setVisible(true);
        		}
			}
		});
        
		JLabel lblInOrderTo = new JLabel("To insert testing results press here:");
		lblInOrderTo.setBounds(673, 136, 203, 14);
		step2Pane.add(lblInOrderTo);
		
		step3Pane = new JPanel();
		step3Pane.setBounds(10, 232, 876, 140);
		mainPanel.add(step3Pane);
		step3Pane.setBorder(new TitledBorder(null, "Step 3 : Choose the testing results", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		step3Pane.setLayout(null);
		
		JLabel label = new JLabel("");
		label.setBounds(10, 20, 51, 37);
		step3Pane.add(label);
		label.setIcon(new ImageIcon(TestingPanel.class.getResource("/GUI/Image/5_content_paste.png")));
		
		RdbtnPassed = new JRadioButton("Testing Passed");
		RdbtnPassed.setFont(new Font("Tahoma", Font.PLAIN, 12));
		RdbtnPassed.setBounds(90, 62, 152, 23);
		step3Pane.add(RdbtnPassed);
		
		RdbtnFailed = new JRadioButton("Testing Failed");
		RdbtnFailed.setFont(new Font("Tahoma", Font.PLAIN, 12));
		RdbtnFailed.setBounds(310, 62, 109, 23);
		step3Pane.add(RdbtnFailed);
		
		FailReportPanel = new JPanel();
		FailReportPanel.setBackground(SystemColor.menu);
		FailReportPanel.setBounds(457, 11, 409, 118);
		step3Pane.add(FailReportPanel);
		FailReportPanel.setLayout(null);
		FailReportPanel.setVisible(false);
		
		JLabel lblFile = new JLabel("Add Information for Testing Failure Report");
		lblFile.setBounds(17, 0, 246, 29);
		FailReportPanel.add(lblFile);
		lblFile.setFont(new Font("Tahoma", Font.PLAIN, 11));
		
		textArea = new JTextArea();
		textArea.setFont(new Font("Tahoma", Font.PLAIN, 11));
		textArea.setBounds(10, 25, 389, 82);
		FailReportPanel.add(textArea);
		step3Pane.setVisible(false);
		
		this.btnAskForMoreTime.setIcon(new ImageIcon(ReviewAndDecisionGUI.class.getResource("/ICONS/10_device_access_time.png")));
		this.btnAskForMoreTime.setBounds(442, 11, 65, 32);
		this.btnAskForMoreTime.setVisible(true);

	}

	
	

	@Override
	public String apHelpButton() {
		return "In this screen you need to decide if the testing passed";
	}

	@Override
	public String setTitle() {
		
			return "Testing";
		
	}
	
	
	
	public void setTxtInfoSystem(String InfoSystem) {
		txtInfoSystem.setText(InfoSystem) ;
	}
	public void setTxtInitiator(String Initiator) {
		txtInitiator.setText(Initiator) ;
	}
	public void setTxtPropChange(String PropChange) {
		txtPropChange.setText(PropChange) ;
	}
	public void setTxtExcuse(String Excuse) {
		txtExcuse.setText(Excuse) ;
	}
	public void setTxtNotes(String Notes) {
		txtNotes.setText(Notes) ;
	}
	public void setTxtDescription(String Description) {
		txtDescription.setText(Description);
	}
	public void setTxtCreationDate(Date CreationDate) {
		TxtCreationDate.setText(CreationDate.toString()); 
	}
	
	public JRadioButton getRdbtnPassed() {
		return RdbtnPassed;
	}

	public JRadioButton getRdbtnFailed() {
		return RdbtnFailed;
	}
	
	public JButton getBtnTestingResult() {
		return btnTestingResult;
	}
	
	public JTextArea getTextArea() {
		return textArea;
	}

	public JPanel getFailReportPanel() {
		return FailReportPanel;
	}


	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}


}
